package com.zc.commons.utils;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;

public class ExcelUtil {

    public static String getCellValueStr(Cell cell) {
        if (cell == null) {
            return "";
        }
        CellType cellType = cell.getCellType();
        String value = "";
        switch (cellType) {
            case STRING:
                value = cell.getStringCellValue();
                break;
            case BOOLEAN:
                boolean booleanValue = cell.getBooleanCellValue();
                value = String.valueOf(booleanValue);
                break;
            case NUMERIC:
                double numericValue = cell.getNumericCellValue();
                value = String.valueOf(numericValue);
                break;
            case FORMULA:
                String cellFormula = cell.getCellFormula();
                value = cellFormula;
                break;
            default:
                break;

        }
        return value;
    }


}
